package com.rpframework.website.device.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.rpframework.core.BaseService;
import com.rpframework.utils.NumberUtils;
import com.rpframework.utils.Pager;
import com.rpframework.website.device.dao.IUnitDao;
import com.rpframework.website.device.domain.Guide;
import com.rpframework.website.device.domain.Interact;
import com.rpframework.website.device.domain.Unit;

/**
 * 
 * @author zhangli
 * @date 2016年3月23日 下午5:50:24
 */
@Service
public class UnitService extends BaseService {
	public  @Resource IUnitDao iDao;
	
	
	public Pager<Unit> getPager(Pager<Unit> pager) {
		List<Unit> list = iDao.doPager(this.packageMyBatisParam(pager));
		pager.setItemList(list);
		return pager;
	}


	public boolean doSaveOrUpdate(Unit t) {
		if(t == null) {
			throw new IllegalArgumentException("非法参数!");
		}
		if(NumberUtils.isValid(t.getId())) {
			Unit DBUtils = iDao.select(t.getId());
			Assert.notNull(DBUtils, "更新时找不到实体 " + t.getId());
			}
			return iDao.update(t);
	}


	
	


}
